<?php
class FormAjSeance{
private $numero;
private $libelleSeance;
private $dateSeance;
private $timeSeance;
private $numEP;
private $groupe;
private $erreurs=array();

function __construct($numero, $libelleSeance, $dateSeance, $timeSeance, $numEP, $groupe) {
    $this->numero = $numero;
    $this->libelleSeance = $libelleSeance;
    $this->dateSeance = $dateSeance;
    $this->timeSeance = $timeSeance;
    $this->numEP = $numEP;
    if($groupe==""){
    $this->groupe = 'NULL';
    }else{
    $this->groupe = $groupe;
        
    }
    
}
public static function bind(){
        $numero = isset($_POST["numero"]) ? $_POST["numero"] : null;
        $libelleSeance = isset($_POST["libelleSeance"]) ? $_POST["libelleSeance"] : null;
        $dateSeance = isset($_POST["dateSeance"]) ? $_POST["dateSeance"] : null;
        $timeSeance = isset($_POST["timeSeance"]) ? $_POST["timeSeance"] : null;
        $groupe = isset($_POST["groupe"]) ? $_POST["groupe"] : null;
        $numEP = isset($_POST["numEp"]) ? $_POST["numEp"] : null;
        
        return new FormAjSeance($numero, $libelleSeance, $dateSeance, $timeSeance, $numEP, $groupe);
}
public function save($bda, $user){
    $bda->ajouterSeance($this->getNumero(), $this->getLibelleSeance(), $this->getDateSeance(),$this->getTimeSeance(), $user["NumUtilisateur"],$this->getGroupe(), $this->getNumEP());
        
}
public function isValid(){
    $isValid=true;
    $attributes =get_object_vars($this);
        foreach ($attributes as $key => $value) {
            if($key!="groupe"){
                if($value==""){
                    $this->erreurs[$key]="Champs obligatoire";
                    $isValid=false;
                }
            }
        }    
    return $isValid;
}

public function getGroupe() {
    return $this->groupe;
}

public function setGroupe($groupe) {
    $this->groupe = $groupe;
}

public function getNumEP() {
    return $this->numEP;
}

public function setNumEP($numEP) {
    $this->numEP = $numEP;
}

public function getNumero() {
    return $this->numero;
}

public function getLibelleSeance() {
    return $this->libelleSeance;
}

public function getDateSeance() {
    return $this->dateSeance;
}
public function setNumero($numero) {
    $this->numero = $numero;
}

public function setLibelleSeance($libelleSeance) {
    $this->libelleSeance = $libelleSeance;
}

public function setDateSeance($dateSeance) {
    $this->dateSeance = $dateSeance;
}
public function getTimeSeance() {
    return $this->timeSeance;
}

public function setTimeSeance($timeSeance) {
    $this->timeSeance = $timeSeance;
}

public function getErreurs() {
    return $this->erreurs;
}

public function setErreurs($erreurs) {
    $this->erreurs = $erreurs;
}

public function getErreur($attribute_name) {
return isset($this->erreurs[$attribute_name])?$this->erreurs[$attribute_name]:null;
}
}
?>